//
//  HXNotifyDetailsViewController.m
//  KD
//
//  Created by Hubery on 16/2/4.
//  Copyright © 2016年 ifly. All rights reserved.
//

#import "HXNotifyDetailsViewController.h"
#import "UIImageView+WebCache.h"
#import "HXRevertViewController.h"

@interface HXNotifyDetailsViewController ()<BMKLocationServiceDelegate>
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *contentLabel;
@property (weak, nonatomic) IBOutlet UILabel *sendPersonLabel;
@property (weak, nonatomic) IBOutlet UIImageView *imageOneImageView;
@property (weak, nonatomic) IBOutlet UIImageView *imageTwoImageView;
@property (nonatomic,strong) HXNotifyDetailsModel *data;

@property (nonatomic,strong) BMKLocationService * locService;


@end

@implementation HXNotifyDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (void)setMessageDict:(NSMutableDictionary *)messageDict{
    _messageDict = messageDict;
    [NetworkAPI notifyDetailsWithMessageId:[_messageDict objectForKey:@"data.MessageID"]
                                  tMUserID:[_messageDict objectForKey:@"data.TMUserID"]
                                  userKind:@"0"
                                   success:^(HXNotifyDetailsModel *result) {
                                       if ([result.code isEqualToString:@"200"]) {
                                           [SVProgressHUD showSuccessWithStatus:@"获取成功"];
                                           self.data = result;
                                           [self setUpdata:result];
                                       }
                                   } failure:^(NSError *err) {
                                       [SVProgressHUD showErrorWithStatus:@"网络错误"];
                                   }];
    
}

-(void)setUpdata:(HXNotifyDetailsModel *)data{
    self.titleLabel.text = data.details.Title;
    self.contentLabel.text = data.details.Content;
    self.sendPersonLabel.text = [NSString stringWithFormat:@"%@  %@",data.details.Author,data.details.SendDate];
    if (data.piclist.count>0) {
            HXNotifyDetailsPictListModel *pictone = data.piclist[0];
        [self.imageOneImageView sd_setImageWithURL:[NSURL URLWithString:pictone.Files_Path] placeholderImage:[UIImage imageNamed:@"loading"] options:SDWebImageRetryFailed|SDWebImageLowPriority|SDWebImageCacheMemoryOnly completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
            if (error) {//errorimage网络错题图片
                self.imageOneImageView.image = [UIImage imageNamed:@""];
            }
        }];
    }else{
        self.imageOneImageView.image = [UIImage imageNamed:@""];
    }
    if (data.piclist.count>1) {
            HXNotifyDetailsPictListModel *picttwo = data.piclist[1];
        [self.imageTwoImageView sd_setImageWithURL:[NSURL URLWithString:picttwo.Files_Path] placeholderImage:[UIImage imageNamed:@"loading"] options:SDWebImageRetryFailed|SDWebImageLowPriority|SDWebImageCacheMemoryOnly completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
            if (error) {
                self.imageTwoImageView.image = [UIImage imageNamed:@""];
            }
        }];
    }else{//noimage没有图片名称
        self.imageTwoImageView.image = [UIImage imageNamed:@""];
    }
    
}

@end
